﻿using System;
using System.Data;
using System.Collections.Generic;

namespace LDSP.BRL
{
    public partial class R_User_ViewPlan : BYFW.BOL.BaseEntity
    {
        public R_User_ViewPlan()
        {
            m_tableName = "t_r_user_viewplan";
            m_tblCacheManager.IsEnable = true;
        }

        protected string m_userType = string.Empty;
        protected int m_userId = 0;
        protected int m_planId = 0;
        protected DateTime m_viewDT = DateTime.MinValue;

        /// <summary>
        /// 用户类型
        /// </summary>
        public string UserType
        {
            get { return m_userType; }
            set { m_userType = value; }
        }
        /// <summary>
        /// 用户ID
        /// </summary>
        public int UserId
        {
            get { return m_userId; }
            set { m_userId = value; }
        }
        /// <summary>
        /// 任务ID
        /// </summary>
        public int PlanId
        {
            get { return m_planId; }
            set { m_planId = value; }
        }
        /// <summary>
        /// 查看时间
        /// </summary>
        public DateTime ViewDT
        {
            get { return m_viewDT; }
            set { m_viewDT = value; }
        }

        protected override void FillContainer()
        {
            base.FillContainer();
            m_container.Add("userType", m_userType);
            m_container.Add("userId", m_userId);
            m_container.Add("planId", m_planId);
            m_container.Add("viewDT", m_viewDT);
        }

        public override bool GetProperties(System.Data.DataRow record)
        {
            if (!base.GetProperties(record))
            {
                return false;
            }
            m_userType = this.GetStringValue(record, "userType");
            m_userId = this.GetIntValue(record, "userId");
            m_planId = this.GetIntValue(record, "planId");
            m_viewDT = this.GetDateValue(record, "viewDT");
            return true;
        }

        public R_User_ViewPlan GetByUserAndPlan(int userId, int planId)
        {
            R_User_ViewPlan uvp = null;
            List<R_User_ViewPlan> uvps = new R_User_ViewPlan().GetSpecialList<R_User_ViewPlan>(null, "where userId = " + userId + " and planId = " + planId);
            if (uvps.Count > 0)
            {
                uvp = uvps[0];
            }

            return uvp;
        }
    }
}